package com.cnswhy.cloud.server.system.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cnswhy.cloud.common.core.utils.SystemClockUtil;
import com.cnswhy.cloud.server.system.dao.SystemUserMapper;
import com.cnswhy.cloud.server.system.entity.SystemUser;
import com.cnswhy.cloud.server.system.service.SystemUserService;
import com.cnswhy.cloud.common.core.base.service.SuperServiceImpl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * <p>
 * 业务实现类
 * 用户表
 * </p>
 *
 * @author cnswhy
 * @date 2020-10-24
 */
@Slf4j
@Service

public class SystemUserServiceImpl extends SuperServiceImpl<SystemUserMapper, SystemUser> implements SystemUserService {
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateLoginTime(String username) {
        SystemUser user = new SystemUser();
        user.setLastLoginTime(SystemClockUtil.getLocalDateTime());

        this.baseMapper.update(user, new LambdaQueryWrapper<SystemUser>().eq(SystemUser::getUsername, username));
    }
}
